package com.yjd.comm.borrow.service;

import java.util.Map;

import com.yjd.comm.base.model.PagerModel;
import com.yjd.comm.base.service.IBaseService;
import com.yjd.comm.borrow.dto.Audit1AppointSubmitDto;
import com.yjd.comm.borrow.dto.AuditSubmitDto;
import com.yjd.comm.borrow.dto.BidSubmitDto;
import com.yjd.comm.borrow.dto.BidSubmitResultDto;
import com.yjd.comm.borrow.dto.BorrowDto;
import com.yjd.comm.borrow.dto.BorrowStep1Dto;
import com.yjd.comm.borrow.dto.BorrowStep2Dto;
import com.yjd.comm.borrow.dto.OverdueDto;
import com.yjd.comm.borrow.model.ArrearsFormModel;
import com.yjd.comm.borrow.model.BorrowModel;
import com.yjd.comm.easycard.dto.EasycardBorrowDTO;
import com.yjd.comm.easycard.model.EasycardModel;
import com.yjd.comm.system.dto.OperParamDto;
import com.yjd.comm.user.model.UserModel;

/**
 * <b>description</b>：hxx_borrow业务接口<br>
 * <b>time</b>：2014-11-07 15:16:16 <br>
 * <b>author</b>： qijingyu qijingyu2009@gmail.com
 */
public interface IBorrowService extends IBaseService {
	/**
	 * 插入
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public BorrowModel insert(BorrowModel model) throws Exception;

	/**
	 * 更新,大于等于1表示成功，其他失败
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public int update(BorrowModel model) throws Exception;

	/**
	 * 根据id删除,大于等于1表示成功，其他失败
	 * 
	 * @param borrowId
	 * @return
	 * @throws Exception
	 */
	public int delete(Long borrowId) throws Exception;

	/**
	 * 获取借款人还处于借款状态的借款信息
	 * 
	 * @param user_id
	 * @return
	 * @throws Exception
	 */
	public BorrowDto getInApplyBorrow(Long user_id) throws Exception;

	/**
	 * 借款申请第一步，提交申请信息
	 * 
	 * @param borrowStep1Dto
	 * @return
	 * @throws Exception
	 */
	public Long applyStep1(BorrowStep1Dto borrowStep1Dto) throws Exception;

	/**
	 * 借款申请第二步，提交申请信息，返回标的信息
	 * 
	 * @param borrowStep1Dto
	 * @return
	 * @throws Exception
	 */
	public BorrowDto applyStep2(BorrowStep2Dto dto) throws Exception;

	/**
	 * 提交当前最新的借款申请
	 * 
	 * @param userid
	 * @return
	 * @throws Exception
	 */
	public boolean applyStep4(Long user_id) throws Exception;

	/**
	 * 获取借款列表
	 * 
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("rawtypes")
	public PagerModel getBorrows(Map paramMap) throws Exception;

	/**
	 * 指定风控人员
	 * 
	 * @param audit1AppointSubmitDto
	 * @param operParamDto
	 * @throws Exception
	 */
	public void auditPoint(Audit1AppointSubmitDto audit1AppointSubmitDto,
			OperParamDto operParamDto) throws Exception;

	/**
	 * 自动分配风控管理权限
	 * 
	 * @throws Exception
	 */
	public void autoPoint() throws Exception;

	/**
	 * 初审
	 * 
	 * @param auditSubmitDto
	 *            审核信息
	 * @param operParamDto
	 *            操作参数信息
	 * @return
	 * @throws Exception
	 */
	public boolean audit1Submit(AuditSubmitDto auditSubmitDto,
			OperParamDto operParamDto) throws Exception;

	/**
	 * 复审
	 * 
	 * @param auditSubmitDto
	 *            审核信息
	 * @param operParamDto
	 *            操作参数信息
	 * @return
	 * @throws Exception
	 */
	public boolean audit2Submit(AuditSubmitDto auditSubmitDto,
			OperParamDto operParamDto) throws Exception;

	/**
	 * 发布标的
	 * 
	 * @param auditSubmitDto
	 *            审核信息
	 * @param operParamDto
	 *            操作参数信息
	 * @return
	 * @throws Exception
	 */
	public boolean audit3Submit(AuditSubmitDto auditSubmitDto,
			OperParamDto operParamDto) throws Exception;

	/**
	 * 统计
	 * 
	 * @param paramMap
	 * @param write
	 * @return
	 * @throws Exception
	 */
	public double borrowSum(Map<Object, Object> paramMap, String field)
			throws Exception;

	/**
	 * 投标，返回投标记录的id，通过捕获异常来处理各种投标失败的情况
	 * 
	 * @param bidSubmitDto
	 * @return
	 * @throws Exception
	 */
	public BidSubmitResultDto bid(BidSubmitDto bidSubmitDto) throws Exception;

	/**
	 * 满标审核
	 * 
	 * @param auditSubmitDto
	 * @param operParamDto
	 * @return
	 * @throws Exception
	 */
	public boolean audit4Submit(AuditSubmitDto auditSubmitDto,
			OperParamDto operParamDto) throws Exception;

	/**
	 * 还款操作(没有异常则表示成功)，需捕获 BaseException异常，内部有异常信息
	 * 
	 * @param arrearsFormId
	 * @throws Exception
	 */
	public void repaysubmit(Long arrearsFormId) throws Exception;

	/**
	 * 垫付(没有异常则表示成功)，需捕获 BaseException异常，内部有异常信息
	 * 
	 * @param arrearformId
	 *            还款报表id
	 * @param operParamDto
	 *            操作信息
	 * @throws Exception
	 */
	public void advance(Long arrearsformId, OperParamDto operParamDto)
			throws Exception;

	/**
	 * 获取还款报表对象的逾期信息(此处将投资人回款报表的逾期信息都加起来得到借款人的逾期费用信息，可以保持借款人逾期费用和受益人获取的罚息相同)
	 * 
	 * @param afm
	 * @param curtime 若为空，取当前时间
	 * @return
	 * @throws Exception
	 */
	public OverdueDto getOdtByArrearsForms(ArrearsFormModel afm, Long curtime)
			throws Exception;

	/**
	 * 获取某个用户在某个标中还可以投入的金额
	 * 
	 * @param borrow_id
	 * @param user_id
	 * @return
	 * @throws Exception
	 */
	public double getUserCanInvestInBorrow(Long borrow_id, Long user_id)
			throws Exception;
	
	/**
	 * 保存易借卡申请借款申请信息
	 * @return 保存的借款申请记录ID
	 * @throws Exception
	 */
	public Long saveInApplyEasycardBorrowInfo(EasycardBorrowDTO easycardBorrowDTO,EasycardModel cardModel)throws Exception;
	/**
	 * 得到易借卡申请借款的借款信息
	 * @param user_id 当前登录用户ID
	 * @return
	 * @throws Exception
	 */
	public EasycardBorrowDTO getInApplyEasycardBorrowInfo(Long user_id)throws Exception;
	/**
	 * 保存易借卡申请信息
	 * @param borrowModelDTO
	 * @throws Exception
	 */
	public void saveEasycardBorrowData(EasycardBorrowDTO borrowModelDTO,UserModel user,EasycardModel cardModel)throws Exception;
	
	
	/**
	 * 检查是否存在 已经在申请的借款,只有复审通过后才可以再次申请借款
	 * @return
	 * @throws Exception
	 */
	public BorrowModel check_easycard_borrowstatus(UserModel user) throws Exception;
	
	/**
	* 获取可投入金额
	* @param borrowModel
	* @return
	* @throws Exception
	 */
	public double getCanInvest(BorrowModel borrowModel,long user_id) throws Exception;

}
